package cc.yihy.storage.aliyun;

import cc.yihy.storage.StorageClient;
import cc.yihy.storage.aliyun.bean.SimpleAliYunOSSClient;
import com.aliyun.oss.OSSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Yihy
 * @version V1.0
 * @Package cc.yihy.storage
 * @Description:
 * @date 2017/6/27 15:29
 */

@Configuration
@ConditionalOnClass({OSSClient.class})
@EnableConfigurationProperties(value = AliYunProperties.class)
public class AliYunAutoConfiguration {

    @Autowired
    private AliYunProperties aliYunProperties;


    @Bean
    @ConditionalOnMissingBean
    public StorageClient aliYunFileClient() {
        return new SimpleAliYunOSSClient(aliYunProperties);
    }
}


